//
//  PersonalSettingPassWordView.m
//  ChatForHot
//
//  Created by wr on 2018/10/17.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "PersonalSettingPassWordView.h"

@interface PersonalSettingPassWordView ()

@property (nonatomic,strong) UIView *HOTCHATbkgview;
@property (nonatomic,strong) UIView *HOTCHATfirstLine;
@property (nonatomic,strong) UIView *HOTCHATsecLine;
@property (nonatomic,strong) UIView *HOTCHATthdLine;

@property (nonatomic,strong) UILabel *HOTCHATidLable;
@property (nonatomic,strong) UILabel *HOTCHATcurrentCodeLabel;
@property (nonatomic,strong) UILabel *HOTCHATInfoLabel;

@property (nonatomic,strong) UITextField *HOTCHATnewWordTextField;
@property (nonatomic,strong) UITextField *HOTCHATconfirmTextField;

@property (nonatomic,strong) UIButton *HOTCHATsaveBtn;
@end

@implementation PersonalSettingPassWordView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self HOTCHATdidInitialized];
    }
    return self;
}

- (void)HOTCHATdidInitialized {
    @weakify(self)
    
    self.HOTCHATbkgview = [[UIView alloc] init];
    self.HOTCHATbkgview.backgroundColor = [UIColor whiteColor];
    self.HOTCHATbkgview.layer.cornerRadius = 8;
    self.HOTCHATbkgview.clipsToBounds = YES;
    self.HOTCHATbkgview.layer.borderWidth = 0.5;
    UIColor *color = HOTCHATrgb(230, 230, 230);
    self.HOTCHATbkgview.layer.borderColor = color.CGColor;
    [self addSubview:self.HOTCHATbkgview];
    
    self.HOTCHATfirstLine = [[UIView alloc] init];
    self.HOTCHATfirstLine.backgroundColor = HOTCHATrgb(230, 230, 230);
    [self addSubview:self.HOTCHATfirstLine];
    
    self.HOTCHATsecLine = [[UIView alloc] init];
    self.HOTCHATsecLine.backgroundColor = HOTCHATrgb(237, 237, 237);
    [self addSubview:self.HOTCHATsecLine];
    
    self.HOTCHATthdLine = [[UIView alloc] init];
    self.HOTCHATthdLine.backgroundColor = HOTCHATrgb(237, 237, 237);
    [self addSubview:self.HOTCHATthdLine];
    
    self.HOTCHATidLable = [[UILabel alloc] init];
    self.HOTCHATidLable.font = [UIFont systemFontOfSize:14];
    self.HOTCHATidLable.textColor = HOTCHATrgb(51, 51, 51);
    self.HOTCHATidLable.text = [NSString stringWithFormat:@"ID:%@",[APPINFO defaultManager].accountNumber];
    [self addSubview:self.HOTCHATidLable];
    
    self.HOTCHATcurrentCodeLabel = [[UILabel alloc] init];
    self.HOTCHATcurrentCodeLabel.font = [UIFont systemFontOfSize:14];
    self.HOTCHATcurrentCodeLabel.textColor = HOTCHATrgb(102, 102, 102);
    self.HOTCHATcurrentCodeLabel.text = [APPINFO defaultManager].password;
    [self addSubview:self.HOTCHATcurrentCodeLabel];
    
    self.HOTCHATInfoLabel = [[UILabel alloc] init];
    self.HOTCHATInfoLabel.font = [UIFont systemFontOfSize:12];
    self.HOTCHATInfoLabel.textColor = HOTCHATrgb(102, 102, 102);
    self.HOTCHATInfoLabel.textAlignment = NSTextAlignmentRight;
    self.HOTCHATInfoLabel.text = NSLocalizedString(@"personS6", nil);
    [self addSubview:self.HOTCHATInfoLabel];
    
    self.HOTCHATnewWordTextField = [[UITextField alloc] init];
    self.HOTCHATnewWordTextField.font = [UIFont systemFontOfSize:14];
    self.HOTCHATnewWordTextField.textColor = HOTCHATrgb(51, 51, 51);
    self.HOTCHATnewWordTextField.placeholder = NSLocalizedString(@"personS7", nil);
    self.HOTCHATnewWordTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.HOTCHATnewWordTextField.secureTextEntry = YES;
    [self addSubview:self.HOTCHATnewWordTextField];
    
    self.HOTCHATconfirmTextField = [[UITextField alloc] init];
    self.HOTCHATconfirmTextField.font = [UIFont systemFontOfSize:14];
    self.HOTCHATconfirmTextField.textColor = HOTCHATrgb(51, 51, 51);
    self.HOTCHATconfirmTextField.placeholder = NSLocalizedString(@"personS8", nil);
    self.HOTCHATconfirmTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.HOTCHATconfirmTextField.secureTextEntry = YES;
    [self addSubview:self.HOTCHATconfirmTextField];
    
    self.HOTCHATsaveBtn = [[UIButton alloc] init];
    self.HOTCHATsaveBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.HOTCHATsaveBtn setTitle:NSLocalizedString(@"SAVEBUTTON", nil) forState:(UIControlStateNormal)];
    [self.HOTCHATsaveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.HOTCHATsaveBtn setBackgroundImage:[[UIImage imageNamed:@"personal_iden_sav_n"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 20, 1, 20) resizingMode:(UIImageResizingModeStretch)] forState:(UIControlStateNormal)];
    [self.HOTCHATsaveBtn setBackgroundImage:[[UIImage imageNamed:@"personal_iden_sav_n"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 20, 1, 20) resizingMode:(UIImageResizingModeStretch)] forState:(UIControlStateHighlighted)];
    [[self.HOTCHATsaveBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
       @strongify(self)
        if (self.delegate && [self.delegate respondsToSelector:@selector(HOTCHATchangeCode:confirmStr:)]) {
            [self.delegate HOTCHATchangeCode:self.HOTCHATnewWordTextField.text confirmStr:self.HOTCHATconfirmTextField.text];
        }
    }];
    [self addSubview:self.HOTCHATsaveBtn];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.HOTCHATbkgview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(15);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.mas_equalTo(207);
    }];
    
    [self.HOTCHATfirstLine mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.HOTCHATbkgview);
        make.height.mas_equalTo(0.5);
        make.top.equalTo(self.HOTCHATbkgview).offset(80);
    }];
    
    [self.HOTCHATsecLine mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.HOTCHATbkgview).offset(20);
        make.right.equalTo(self.HOTCHATbkgview).offset(-20);
        make.height.mas_equalTo(1);
        make.top.equalTo(self.HOTCHATfirstLine).offset(50);
    }];
    [self.HOTCHATthdLine mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.HOTCHATbkgview).offset(20);
        make.right.equalTo(self.HOTCHATbkgview).offset(-20);
        make.height.mas_equalTo(1);
        make.top.equalTo(self.HOTCHATsecLine).offset(50);
    }];
    
    [self.HOTCHATidLable mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.HOTCHATbkgview).offset(18);
        make.left.equalTo(self.HOTCHATbkgview).offset(20);
        make.height.mas_equalTo(18);
    }];
    [self.HOTCHATcurrentCodeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.HOTCHATidLable.mas_bottom).offset(16);
        make.left.equalTo(self.HOTCHATidLable);
        make.height.mas_equalTo(18);
    }];
    [self.HOTCHATInfoLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.HOTCHATcurrentCodeLabel);
        make.right.equalTo(self.HOTCHATbkgview).offset(-20);
    }];
    
    [self.HOTCHATnewWordTextField mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.HOTCHATsecLine);
        make.top.equalTo(self.HOTCHATfirstLine).offset(13);
        make.bottom.equalTo(self.HOTCHATsecLine.mas_top);
    }];
    
    [self.HOTCHATconfirmTextField mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.HOTCHATsecLine);
        make.top.equalTo(self.HOTCHATsecLine).offset(13);
        make.bottom.equalTo(self.HOTCHATthdLine.mas_top);
    }];
    
    [self.HOTCHATsaveBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.HOTCHATbkgview);
        make.top.equalTo(self.HOTCHATbkgview.mas_bottom).offset(15);
        make.height.mas_equalTo(45);
    }];
}
@end
